Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pip-tools (GSI 334) #160

Merged
merged 34 commits into from
Sep 20, 2023
Merged

Use pip-tools (GSI 334) #160

merged 34 commits into from
Sep 20, 2023

Conversation

TheByronHimes
Copy link
Member

@TheByronHimes TheByronHimes commented Sep 19, 2023

Motivation

Up until now, we have managed our project dependencies in a semi-loose fashion where we only pinned top-level dependencies and allowed pip to resolve everything else as it saw fit. This mostly worked okay but we really wanted a way to lock down dependencies to ensure reproducibility and avoid the it works on my machine problem. We evaluated a few options, including Poetry, PDM, and pip-tools, and ultimately decided on the latter because it meshed well with what we already had, allowed us to switch to pyproject.toml from setup.cfg, is still actively maintained and relatively popular.

Changes

Dependencies

The line in dev_install that installs dependencies now includes --no-deps and installs exclusively from requirements-dev.txt.
The rationale for this is described in this PR.
Top-level dependencies have been moved as follows:

  • Production dependencies: setup.cfg -> pyproject.toml
  • Repo-specific dev dependencies: requirements-dev.txt -> requirements-dev.in
  • Common dev dependencies: requirements-dev-common.in -> requirements-dev-common.in

Github Workflows

  • We're now using v3 of gh-action-common, which was updated to reflect the changes here.

New

  • New update_lock.py in /scripts/ (originally written by @KerstenBreuer)
    • Script used to create/update requirements.txt and requirements-dev.txt (the lock files).
    • scripts/update_lock.py [--upgrade]
    • --upgrade will tell pip-compile to reevaluate dependencies that are already in the lock file (if it exists).
    • --check will compare the current and would-be files to see if an update is needed.
  • pyproject.toml (PEP 621) is where project information and dependencies are defined. It replaces setup.cfg.
  • requirements-dev.txt: lock file that contains all pinned dependencies for the repository, both top-level and transitive, and their hashes.
  • requirements.txt: lock file containing the production-only dependencies. This is a subset of requirements-dev.txt.

Add a print statement for each file being updated (as it takes a while)

Include all-extras flag only if optional-deps is present in TOML file
Remove the setup files from that list too
Prevent redundant package dep resolution that may result in errors
Reqs should be installed exactly as specified in lock file
Fix error message capture/output if command fails
Make src dir next to TOML to satisfy build system
Create dev lock file before production lock file
Fix "@3" gh action reference to say "@V3"
Copy link
Contributor

@KerstenBreuer KerstenBreuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just a few small suggestions.

.devcontainer/dev_install Outdated Show resolved Hide resolved
.github/workflows/check_config_docs.yaml Outdated Show resolved Hide resolved
.github/workflows/check_openapi_spec.yaml Outdated Show resolved Hide resolved
.mandatory_files Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
requirements-dev-common.in Outdated Show resolved Hide resolved
requirements-dev.in Outdated Show resolved Hide resolved
requirements.in Outdated Show resolved Hide resolved
scripts/get_package_name.py Show resolved Hide resolved
scripts/update_lock.py Show resolved Hide resolved
Cito
Cito previously approved these changes Sep 19, 2023
Copy link
Member

@Cito Cito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Just two slight comments, feel free to ignore them.

scripts/update_lock.py Outdated Show resolved Hide resolved
scripts/update_lock.py Outdated Show resolved Hide resolved
Add setup.cfg/.py to deprecated files

Use no-deps in package install command in dev_install

Use ~= on production deps < 1.0.0 in pyproject.toml

Remove extra newlines in pyproject.toml

Remove old comments from requirements-dev-common.in
@github-actions
Copy link

github-actions bot commented Sep 19, 2023

Pull Request Test Coverage Report for Build 6247490190

  • 0 of 2 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 0.0%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/my_microservice/init.py 0 2 0.0%
Totals Coverage Status
Change from base Build 5601358819: 0.0%
Covered Lines: 0
Relevant Lines: 72

💛 - Coveralls

Require the lock files (mandatory)

Remove requirements.txt from static files
@TheByronHimes TheByronHimes merged commit cdcae8a into main Sep 20, 2023
6 checks passed
@TheByronHimes TheByronHimes deleted the feature/pip_tools_GSI-334 branch September 20, 2023 12:31
@TheByronHimes TheByronHimes mentioned this pull request Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants